import { MockMethod } from 'vite-plugin-mock'

function createUserList() {
  return [
    {
      userId: '1',
      avatar: 'https://foruda.gitee.com/avatar/1677185369356157260/9720132_zhangquanwwei_1631794768.png',
      username: 'wei',
      password: 'admin',
      desc: '超级管理员',
      roles: ['超级管理员'],
      buttons: ['cuser.detail'],
      routes: ['home'],
      token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZWFsTmFtZSI6IjcxNDExOTM4IiwicGFzc3dvcmQiOiIyMzhjOWEwYmU0YWE0NzY4OWNkODA3MmJjOWJiYzdmZiIsImFjY291bnQiOiI3MTQxMTkzOCJ9.mf7TaIJr15r4U1slfE_lsROQypIJaopZdZC0PdM0kuY'
    },
    {
      userId: '2',
      avatar: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      username: 'duck',
      password: '123456',
      desc: '访客',
      roles: ['访客'],
      buttons: ['cuser.detail'],
      routes: ['home'],
      token: 'System Token'
    },
  ]
}

function toolsList() {
  return [
    {
      id: 'md5jm1',
      title: 'MD5加密',
      path: 'md5',
      icon: 'Lock'
    },
    {
      id: 'base64jm2',
      title: 'BASE64加密',
      path: 'base64',
      icon: 'Lock'
    },
    {
      id: 'yhhy3',
      title: '英汉互译',
      path: 'translate',
      icon: 'Switch'
    },
    {
      id: 'jsq4',
      title: '计算器',
      path: 'calculator',
      icon: 'Cpu'
    },
    {
      id: 'scewm5',
      title: '生成二维码',
      path: 'qrcode',
      icon: 'PictureFilled'
    },
    {
      id: 'dtgn6',
      title: '地图功能',
      path: 'map',
      icon: 'MapLocation'
    },
    {
      id: 'hlhs7',
      title: '汇率换算',
      path: 'exchange',
      icon: 'Sort'
    },
    {
      id: 'gpzs8',
      title: '股票走势',
      path: 'kline',
      icon: 'TrendCharts'
    },
    {
      id: 'tqzk9',
      title: '天气状况',
      path: 'weather',
      icon: 'Drizzling'
    },
    {
      id: 'szzhq10',
      title: '色值转换器',
      path: 'color',
      icon: 'HelpFilled'
    },
    {
      id: 'szgj11',
      title: '时钟工具',
      path: 'clock',
      icon: 'AlarmClock'
    },
    {
      id: 'wnl12',
      title: '万年历',
      path: 'calendar',
      icon: 'Calendar'
    },
    {
      id: 'xyx13',
      title: '复古游戏',
      path: 'games',
      icon: 'SwitchFilled'
    },
    {
      id: 'dmgsh14',
      title: '代码格式化',
      path: 'jsbeautify',
      icon: 'EditPen'
    },
    {
      id: 'yzgq15',
      title: '演奏钢琴',
      path: 'piano',
      icon: 'Headset'
    },
    {
      id: 'sxb16',
      title: '手写板',
      path: 'write',
      icon: 'Tickets'
    },
    {
      id: 'xydzp17',
      title: '幸运大转盘',
      path: 'wheel',
      icon: 'Orange'
    },
    {
      id: 'xzys18',
      title: '星座运势',
      path: 'constellation',
      icon: 'Star'
    },
    {
      id: 'ctssc19',
      title: '藏头诗生成',
      path: 'poetry',
      icon: 'ScaleToOriginal'
    },
    {
      id: 'jryj20',
      title: '今日油价',
      path: 'gasoline',
      icon: 'NoSmoking'
    },
    {
      id: 'ocrsb21',
      title: 'OCR识别',
      path: 'ocr',
      icon: 'CameraFilled'
    },
    {
      id: 'qsjsq22',
      title: '亲属计算器',
      path: 'relative',
      icon: 'Avatar'
    },
    {
      id: 'jkzs23',
      title: '健康助手',
      path: 'healthy',
      icon: 'Medal'
    },
    {
      id: 'tpys24',
      title: '图片压缩',
      path: 'compressor',
      icon: 'PictureFilled'
    },
    {
      id: 'jqqd99',
      title: '敬请期待',
      path: '',
      icon: 'MoreFilled'
    },
  ]
}

function cityList () {
  return [
    {
      city: '北京',
      adcode: '110000'
    },
    {
      city: '上海',
      adcode: '310100'
    },
    {
      city: '杭州',
      adcode: '330100'
    },
    {
      city: '嘉兴',
      adcode: '330400'
    },
    {
      city: '徐州',
      adcode: '320300'
    },
    {
      city: '天津',
      adcode: '120100'
    },
    {
      city: '南京',
      adcode: '320100'
    },
    {
      city: '长沙',
      adcode: '430100'
    },
    {
      city: '黄冈',
      adcode: '421100'
    },
    {
      city: '青岛',
      adcode: '370200'
    },
    {
      city: '许昌',
      adcode: '411000'
    },
    {
      city: '周口',
      adcode: '411600'
    },
    {
      city: '沈阳',
      adcode: '210100'
    },
    {
      city: '大连',
      adcode: '210200'
    },
    {
      city: '哈尔滨',
      adcode: '230100'
    },
    {
      city: '长春',
      adcode: '220100'
    },
    {
      city: '拉萨',
      adcode: '540100'
    },
    {
      city: '乌鲁木齐',
      adcode: '650100'
    },  
  ]
}

function screenList() {
  return [
    {
      id: '2019',
      money: '33447.18',
      average: '2787.27'
    },
    {
      id: '2020',
      money: '32625.16',
      average: '2718.76'
    },
    {
      id: '2021',
      money: '56070.00',
      average: '4672.50'
    },
    {
      id: '2022',
      money: '83821.79',
      average: '6985.15'
    },
    {
      id: '2023',
      money: '88151.88',
      average: '7345.99'
    },
    {
      id: '2024',
      money: '16243.20',
      average: '5414.40'
    },
  ]
}

function subentryList () {
  return [
    {
      year: '2019',
      list: [] 
    },
    {
      year: '2020',
      list: [] 
    },
    {
      year: '2021',
      list: [] 
    },
    {
      year: '2022',
      list: [] 
    },
    {
      year: '2023',
      list: [
        { value: 15074.6, name: '餐饮' },
        { value: 30465.0, name: '住房' },
        { value: 9421.8, name: '办公' },
        { value: 1806.2, name: '购物' },
        { value: 7458.7, name: '交通' },
        { value: 5346.4, name: '零食' },
        { value: 3158.7, name: '礼金' },
        { value: 5026.1, name: '日用' },
        { value: 1718.7, name: '医疗' },
        { value: 1489.1, name: '通讯' },
        { value: 1308.8, name: '服饰' },
        { value: 1015, name: '罚款' },
        { value: 884.0, name: '娱乐' },
        { value: 761.0, name: '水果' },
        { value: 505.9, name: '美容' },
        { value: 423.3, name: '学习' },
      ]
    },
    {
      year: '2024',
      list: [
        { value: 3110.5, name: '餐饮' },
        { value: 7895.0, name: '住房' },
        { value: 6.4, name: '办公' },
        { value: 146.3, name: '购物' },
        { value: 2297.5, name: '交通' },
        { value: 1485.4, name: '零食' },
        { value: 25.0, name: '礼金' },
        { value: 459.4, name: '日用' },
        { value: 112.2, name: '医疗' },
        { value: 63.0, name: '通讯' },
        { value: 201.9, name: '娱乐' },
        { value: 199.0, name: '服饰' },
        { value: 135.0, name: '学习' },
        { value: 106.6, name: '水果' },
      ]
    }
  ]
}

function fluctuantList() {
  return [
    {
      id: '2019',
      list: []
    },
    {
      id: '2020',
      list: []
    },
    {
      id: '2021',
      list: []
    },
    {
      id: '2022',
      list: []
    },
    {
      id: '2023',
      list: [
        { mon: 'Jan', month: '一月', value: '4861.08' },
        { mon: 'Feb', month: '二月', value: '11094.30' },
        { mon: 'Mar', month: '三月', value: '5288.20' },
        { mon: 'Apr', month: '四月', value: '3174.30' },
        { mon: 'May', month: '五月', value: '11843.20' },
        { mon: 'Jun', month: '六月', value: '4973.20' },
        { mon: 'Jul', month: '七月', value: '3363.30' },
        { mon: 'Aug', month: '八月', value: '10033.70' },
        { mon: 'Sept', month: '九月', value: '14447.80' },
        { mon: 'Oct', month: '十月', value: '5064.10' },
        { mon: 'Nov', month: '十一月', value: '11998.40' },
        { mon: 'Dec', month: '十二月', value: '2569.40' }
      ]
    },
    {
      id: '2024',
      list: [
        { mon: 'Jan', month: '一月', value: '4338.60' },
        { mon: 'Feb', month: '二月', value: '10058.40' },
        { mon: 'Mar', month: '三月', value: '1846.20' },
    //     { mon: 'Apr', month: '四月', value: '' },
    //     { mon: 'May', month: '五月', value: '' },
    //     { mon: 'Jun', month: '六月', value: '' },
    //     { mon: 'Jul', month: '七月', value: '' },
    //     { mon: 'Aug', month: '八月', value: '' },
    //     { mon: 'Sept', month: '九月', value: '' },
    //     { mon: 'Oct', month: '十月', value: '' },
    //     { mon: 'Nov', month: '十一月', value: '' },
    //     { mon: 'Dec', month: '十二月', value: '' }
      ]
    },
  ]
}

function klineList() {
  return [
    // 数据意义：开盘(open)，收盘(close)，最低(lowest)，最高(highest)
    [
      ['2023/09/11', 3125.71, 3155.93, 3113.87, 3142.86],
      ['2023/09/20', 3116.81, 3108.57, 3053.04, 3074.51],
      ['2023/10/09', 3100.00, 3110.00, 3071.00, 3096.92],
      ['2023/10/10', 3104.37, 3109.98, 3073.19, 3075.24],
      ['2023/10/11', 3085.70, 3078.96, 3071.94, 3095.66],
      ['2023/10/12', 3101.71, 3107.90, 3092.18, 3109.99],
      ['2023/10/13', 3092.00, 3088.10, 3080.55, 3094.92],
      ['2023/10/16', 3085.01, 3073.81, 3069.04, 3086.02],
      ['2023/10/17', 3076.43, 3083.50, 3064.89, 3084.07],
      ['2023/10/18', 3076.58, 3058.71, 3057.06, 3076.58],
      ['2023/10/19', 3043.20, 3005.39, 3004.77, 3043.20],
      ['2023/10/20', 2995.36, 2983.06, 2977.17, 3006.27],
      ['2023/10/23', 2969.79, 2939.29, 2923.51, 2973.66],
      ['2023/10/24', 2944.31, 2962.24, 2929.09, 2964.76],
      ['2023/10/25', 2986.41, 2974.11, 2972.42, 2993.30],
      ['2023/10/26', 2960.10, 2988.30, 2956.01, 2990.33],
      ['2023/10/27', 2978.40, 3017.78, 2974.88, 3029.21],
      ['2023/10/30', 3009.61, 3022.90, 3002.35, 3025.36],
      ['2023/10/31', 3019.65, 3018.77, 3006.61, 3023.00],
      ['2023/11/01', 3038.18, 3023.08, 3013.93, 3038.33],
      ['2023/11/02', 3028.66, 3023.08, 3009.12, 3038.64],
      ['2023/11/03', 3012.47, 3030.80, 3012.47, 3040.98],
      ['2023/11/06', 3047.13, 3058.41, 3037.69, 3058.99],
      ['2023/11/07', 3052.92, 3057.27, 3042.47, 3064.58],
      ['2023/11/08', 3051.15, 3052.37, 3037.29, 3062.99],
      ['2023/11/09', 3047.65, 3053.28, 3045.83, 3063.47],
      ['2023/11/10', 3043.56, 3038.97, 3027.09, 3044.00],
      ['2023/11/13', 3044.03, 3046.53, 3028.17, 3048.62],
      ['2023/11/14', 3046.82, 3056.07, 3044.43, 3059.53],
      ['2023/11/15', 3077.03, 3072.83, 3064.35, 3080.13],
      ['2023/11/16', 3066.86, 3050.93, 3050.93, 3071.45],
      ['2023/11/17', 3043.62, 3054.37, 3033.75, 3055.86],
      ['2023/11/20', 3056.93, 3068.32, 3043.51, 3072.51],
      ['2023/11/21', 3074.83, 3067.93, 3063.34, 3089.77],
      ['2023/11/22', 3060.50, 3043.61, 3043.61, 3067.96],
      ['2023/11/23', 3041.68, 3061.86, 3034.30, 3062.87],
      ['2023/11/24', 3060.33, 3040.97, 3037.20, 3060.33],
      ['2023/11/27', 3038.19, 3031.70, 3015.01, 3038.36],
      ['2023/11/28', 3028.60, 3038.55, 3020.23, 3039.69],
      ['2023/11/29', 3038.46, 3021.69, 3017.66, 3038.98],
      ['2023/11/30', 3021.10, 3029.67, 3013.77, 3030.91],
      ['2023/12/01', 3027.35, 3031.64, 3010.23, 3035.76],
      ['2023/12/04', 3033.30, 3022.91, 3022.35, 3038.98],
      ['2023/12/05', 3017.01, 2972.30, 2972.30, 3017.01],
      ['2023/12/06', 2966.95, 2968.93, 2959.60, 2985.31],
      ['2023/12/07', 2965.65, 2966.21, 2949.14, 2976.01],
      ['2023/12/08', 2965.39, 2969.56, 2962.33, 2980.83],
      ['2023/12/11', 2956.29, 2991.44, 2930.42, 2995.67],
      ['2023/12/12', 2986.33, 3003.44, 2980.45, 3003.75],
      ['2023/12/13', 2997.34, 2968.76, 2968.76, 2997.34],
      ['2023/12/14', 2979.70, 2958.99, 2958.07, 2986.18],
      ['2023/12/15', 2966.30, 2942.56, 2940.03, 2976.31],
      ['2023/12/18', 2936.58, 2930.80, 2924.33, 2951.15],
      ['2023/12/19', 2928.76, 2932.39, 2914.13, 2940.50],
      ['2023/12/20', 2932.12, 2902.11, 2902.04, 2937.10],
      ['2023/12/21', 2892.02, 2918.71, 2882.02, 2924.26],
      ['2023/12/22', 2919.29, 2914.78, 2906.51, 2935.70],
      ['2023/12/25', 2909.88, 2918.81, 2903.99, 2920.63],
      ['2023/12/26', 2917.97, 2898.88, 2892.84, 2917.97],
      ['2023/12/27', 2900.15, 2914.61, 2890.16, 2917.96],
      ['2023/12/28', 2913.11, 2954.70, 2909.39, 2961.65],
      ['2023/12/29', 2950.84, 2974.93, 2950.02, 2975.03],
      ['2024/01/02', 2972.78, 2962.28, 2962.28, 2976.27],
      ['2024/01/03', 2957.11, 2967.25, 2953.29, 2971.28],
      ['2024/01/04', 2965.51, 2954.35, 2936.63, 2966.68],
      ['2024/01/05', 2949.82, 2929.18, 2916.72, 2967.97],
      ['2024/01/08', 2923.46, 2887.54, 2887.54, 2924.46],
      ['2024/01/09', 2887.11, 2893.25, 2878.41, 2900.73], // 已清仓
      // ['2024/01/10',]
    ]
  ]
}

export default [
  // 用户登陆接口
  {
    url: '/api/user/login',
    method: 'post',
    response: ({ body }) => {
      const { username, password } = body
      const checkUser = createUserList().find(
        (item) => item.username === username && item.password === password
      )
      if (!checkUser) {
        return {
          code: '403',
          data: { message: '账号或者密码不正确' }
        }
      }
      const { token } = checkUser
      return {
        code: '200',
        data: { token }
      }
    }
  },
  // 获取用户信息
  {
    url: '/api/user/info',
    method: 'post',
    response: ({ body }) => {
      const { token } = body
      const checkUser = createUserList().find(
        (item) => item.token === token
      )
      if (!checkUser) {
        return {
          code: '201',
          data: { message: '获取用户信息失败' }
        }
      }
      return {
        code: '200',
        data: { ...checkUser }
      }
    }
  },
  // 获取工具列表
  {
    url: '/api/tools/info',
    method: 'post',
    response: ({ body }) => {
      const checkTools = toolsList()
      if (!checkTools) {
        return {
          code: '201',
          data: { message: '工具列表查询失败，请稍后再试试' }
        }
      }
      return {
        code: '200',
        data: [...checkTools]
      }
    }
  },
  // 获取账单列表
  {
    url: '/api/screen/info',
    method: 'post',
    response: ({ body }) => {
      const checkScreen = screenList()
      if (!checkScreen) {
        return {
          code: '201',
          data: { message: '账单列表查询失败，请稍后再试试' }
        }
      }
      return {
        code: '200',
        data: [...checkScreen]
      }
    }
  },
  // 获取账单年度项列表
  {
    url: '/api/subentry/info',
    method: 'post',
    response: ({ body }) => {
      const checkSubentry: any = subentryList()
      if (!checkSubentry) {
        return {
          code: '201',
          data: { message: '账单项列表查询失败，请稍后再试试' }
        }
      }
      return {
        code: '200',
        data: [...checkSubentry]
      }
    }
  },
  // 获取账单月度项列表
  {
    url: '/api/fluctuant/info',
    method: 'post',
    response: ({ body }) => {
      const checkFluctuantList: any = fluctuantList()
      if (!checkFluctuantList) {
        return {
          code: '201',
          data: { message: '月度开销列表查询失败，请稍后再试试' }
        }
      }
      return {
        code: '200',
        data: [...checkFluctuantList]
      }
    }
  },
  // 获取城市列表
  {
    url: '/api/city/info',
    method: 'post',
    response: ({ body }) => {
      const checkCity = cityList()
      if (!checkCity) {
        return {
          code: '201',
          data: { message: '城市列表查询失败，请稍后再试试' }
        }
      }
      return {
        code: '200',
        data: [...checkCity]
      }
    }
  },
  // 获取k线列表
  {
    url: '/api/kline/info',
    method: 'post',
    response: ({ body }) => {
      const checkKline = klineList()
      if (!checkKline) {
        return {
          code: '201',
          data: { message: 'k线列表查询失败，请稍后再试试' }
        }
      }
      return {
        code: '200',
        data: [...checkKline]
      }
    }
  },
] as MockMethod[]